//
// Created by Asus on 2025/6/1.
//

#include <iostream>
#include <bits/ostream.tcc>

using namespace std;

void swapInt(int &a, int &b) {
    int temp = a;
    a = b;
    b = temp;
}

void swapDouble(double &a, double &b) {
    double temp = a;
    a = b;
    b = temp;
}

template<typename T>
void mySwap(T &a, T &b) {
    T temp = a;
    a = b;
    b = temp;
}

void demo01() {
    int a = 10;
    int b = 20;
    // swapInt(a, b);
    //利用模板实现交换
    //1、自动类型推导
    // mySwap(a, b);
    //2、显示指定类型
    mySwap<int>(a, b);
    cout << "a:" << a << endl;
    cout << "b:" << b << endl;
}

int main(int argc, char *argv[]) {
    demo01();
    return 0;
}
